package com.hot100;

public class Solution48 {
    public void rotate(int[][] matrix) {
        int i = 0;
        int j = matrix.length - 1;
        for (int k = 0; k < matrix[0].length; k++) {
            while (i < j) {
                matrix[i][k] = matrix[i][k] ^ matrix[j][k];
                matrix[j][k] = matrix[i][k] ^ matrix[j][k];
                matrix[i][k] = matrix[i][k] ^ matrix[j][k];
                i++;
                j--;
            }
            i = 0;
            j = matrix.length - 1;
        }
        for (j = 0; j < matrix[0].length-1; j++) {
            for (i = j+1; i < matrix[0].length; i++) {
                matrix[i][j] = matrix[i][j] ^ matrix[j][i];
                matrix[j][i] = matrix[i][j] ^ matrix[j][i];
                matrix[i][j] = matrix[i][j] ^ matrix[j][i];
            }
        }
    }
}
